package com.ruoyi.web.controller.solidProdution;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.solidProdution.domain.CfEp;
import com.ruoyi.solidProdution.service.ICfEpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 产废企业基本信息Controller
 * 
 * @author ruoyi
 * @date 2021-09-02
 */
@RestController
@RequestMapping("/solidProdution/cfep")
public class CfEpController extends BaseController
{
    @Autowired
    private ICfEpService cfEpService;

    /**
     * 查询产废企业基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfep:list')")
    @GetMapping("/list")
    public TableDataInfo list(CfEp cfEp)
    {
        startPage();
        List<CfEp> list = cfEpService.selectCfEpList(cfEp);
        return getDataTable(list);
    }

    /**
     * 导出产废企业基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfep:export')")
    @Log(title = "产废企业基本信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CfEp cfEp)
    {
        List<CfEp> list = cfEpService.selectCfEpList(cfEp);
        ExcelUtil<CfEp> util = new ExcelUtil<CfEp>(CfEp.class);
        return util.exportExcel(list, "产废企业基本信息数据");
    }

    /**
     * 获取产废企业基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfep:query')")
    @GetMapping(value = "/{cfId}")
    public AjaxResult getInfo(@PathVariable("cfId") Long cfId)
    {
        return AjaxResult.success(cfEpService.selectCfEpById(cfId));
    }

    /**
     * 新增产废企业基本信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfep:add')")
    @Log(title = "产废企业基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CfEp cfEp)
    {
        return toAjax(cfEpService.insertCfEp(cfEp));
    }

    /**
     * 修改产废企业基本信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfep:edit')")
    @Log(title = "产废企业基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CfEp cfEp)
    {
        return toAjax(cfEpService.updateCfEp(cfEp));
    }

    /**
     * 删除产废企业基本信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cfep:remove')")
    @Log(title = "产废企业基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cfIds}")
    public AjaxResult remove(@PathVariable Long[] cfIds)
    {
        return toAjax(cfEpService.deleteCfEpByIds(cfIds));
    }
}
